package com.rogue.blog.model.dto.article;

import com.rogue.blog.model.po.article.ArticlePO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;

/**
 * Created by 86101 on 2018-10-22.
 */
@ApiModel(description = "文章数据传输对象")
@Getter
@Setter
public class ArticleDTO {
    @ApiModelProperty(value = "文章名称")
    private String articleName;
    @ApiModelProperty(value = "文章内容")
    private String articleContent;
    @ApiModelProperty(value = "文章点击量", allowEmptyValue = true)
    private int articleClick;
    @ApiModelProperty(value = "文章简介", allowEmptyValue = true)
    private String articleDescription;
    @ApiModelProperty(value = "文章分类")
    private long articleCategory;
    @ApiModelProperty(value = "文章来源，original:原创，reprint:转载")
    private String articleOrigin;

    public ArticlePO toPO() {
        ArticlePO po = new ArticlePO();
        BeanUtils.copyProperties(this, po);
        return po;
    }

    public String getArticleName() {
        return StringUtils.trim(articleName);
    }
}
